package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.MallFundFlowTransactionType;
import com.rockcent.mall.lib.domain.enumclass.FundTransactionFlow;
import com.rockcent.mall.lib.domain.enumclass.PaymentMethod;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 平台资金流
 */
@Entity
@Table(name = "mall_fund_flow")
@DynamicInsert
@DynamicUpdate
public class MallFundFlow extends IDEntityMall {

    /**
     * 平台订单号 有关订单资金时,此字段不能为空
     */
    @Column(columnDefinition = "varchar(50) comment '平台订单号 有关订单资金时,此字段不能为空'")
    private String mallOrderNum;

    /**
     * 商家订单号 有关订单资金时,此字段不能为空
     */
    @Column(columnDefinition = "varchar(50) comment '商家订单号 有关订单资金时,此字段不能为空'")
    private String merchantOrderNum;

    /**
     * 总金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '总金额'")
    private BigDecimal totalAmount = BigDecimal.valueOf(0);

    /**
     * 冻结金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '冻结金额'")
    private BigDecimal frozen = BigDecimal.valueOf(0);

    /**
     * 可用金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '可用金额'")
    private BigDecimal availableAmount = BigDecimal.valueOf(0);

    /**
     * 备注
     */
    @Column(columnDefinition = "varchar(255) comment '备注'")
    private String remark;

    /**
     * 操作金额
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '操作金额'")
    private BigDecimal operationAmount = BigDecimal.valueOf(0);

    /**
     * 交易方向 INCOME("收入", "+"), EXPEND("支出", "-")
     */
    @Column(columnDefinition = "varchar(50) comment '交易方向 INCOME(\"收入\", \"+\"), EXPEND(\"支出\", \"-\")'")
    @Enumerated(EnumType.STRING)
    private FundTransactionFlow transactionFlow;

    /**
     * 交易类型 SERVICE_FEE("服务费收入")
     */
    @Column(columnDefinition = "varchar(50) comment '交易类型 SERVICE_FEE(\"服务费收入\")'")
    @Enumerated(EnumType.STRING)
    private MallFundFlowTransactionType transactionType;

    /**
     * 支付方式 WECHAT("微信"),CASH_COUPON("现金券"),BALANCE("余额支付")
     */
    @Column(columnDefinition = "varchar(30) comment '支付方式 WECHAT(\"微信\"),CASH_COUPON(\"现金券\"),BALANCE(\"余额支付\"),BASE_SERVICE_PAYMENTS(\"基础服务费扣费\")'")
    @Enumerated(EnumType.STRING)
    private PaymentMethod paymentMethod;

    /**
     * 平台资金 id
     */
    @Column(columnDefinition = "bigint comment '平台资金 id'")
    private Long mallFundId;

    /**
     * 平台 id
     */
    @Column(columnDefinition = "bigint comment '平台 id'")
    private Long mallId;

    /**
     * parent_id
     */
    @Column(columnDefinition = "bigint comment 'parent_id'")
    private Long parentId;


    public String getMallOrderNum() {
        return mallOrderNum;
    }

    public void setMallOrderNum(String mallOrderNum) {
        this.mallOrderNum = mallOrderNum;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getFrozen() {
        return frozen;
    }

    public void setFrozen(BigDecimal frozen) {
        this.frozen = frozen;
    }

    public BigDecimal getAvailableAmount() {
        return availableAmount;
    }

    public void setAvailableAmount(BigDecimal availableAmount) {
        this.availableAmount = availableAmount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public BigDecimal getOperationAmount() {
        return operationAmount;
    }

    public void setOperationAmount(BigDecimal operationAmount) {
        this.operationAmount = operationAmount;
    }

    public FundTransactionFlow getTransactionFlow() {
        return transactionFlow;
    }

    public void setTransactionFlow(FundTransactionFlow transactionFlow) {
        this.transactionFlow = transactionFlow;
    }

    public MallFundFlowTransactionType getTransactionType() {
        return transactionType;
    }

    public void setTransactionType(MallFundFlowTransactionType transactionType) {
        this.transactionType = transactionType;
    }

    public Long getMallFundId() {
        return mallFundId;
    }

    public void setMallFundId(Long mallFundId) {
        this.mallFundId = mallFundId;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getMerchantOrderNum() {
        return merchantOrderNum;
    }

    public void setMerchantOrderNum(String merchantOrderNum) {
        this.merchantOrderNum = merchantOrderNum;
    }

    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    @Override
    public String toString() {
        return "MallFundFlow{" +
                "mallOrderNum='" + mallOrderNum + '\'' +
                ", merchantOrderNum='" + merchantOrderNum + '\'' +
                ", totalAmount=" + totalAmount +
                ", frozen=" + frozen +
                ", availableAmount=" + availableAmount +
                ", remark='" + remark + '\'' +
                ", operationAmount=" + operationAmount +
                ", transactionFlow=" + transactionFlow +
                ", transactionType=" + transactionType +
                ", paymentMethod=" + paymentMethod +
                ", mallFundId=" + mallFundId +
                ", mallId=" + mallId +
                ", parentId=" + parentId +
                '}';
    }
}